################################## 
############ Preamble ############ 
################################## 

# set language to English
Sys.setenv(LANG = "en")

# clean up
rm(list = ls())

# Set working directory: please set your own
#setwd("~/Dropbox/JOP third submission/JOP replication/")

# Load necessary packages
library(tidyverse)
library(readstata13)

# Import dataset
ccaa_2 <- read.dta13("01_data/survey_ccaa_jk_2.dta")

# For showing signs of discomfort
uncomfortable_regionjk_plot <-  ccaa_2 %>%
  filter(Removed != "fake") %>%
  filter(Model == "uncomfortable") %>%
  mutate(ci_lower_90 = coef - 1.645 * stderr) %>%
  mutate(ci_upper_90 = coef + 1.645 * stderr) %>%
  ggplot(aes(x = Removed, y = coef)) +
  geom_hline(aes(yintercept = 0), linetype = 2, color = "red") + 
  coord_flip( ) + 
  geom_linerange(aes(ymin = ci_lower, ymax = ci_upper), position = position_dodge(width = 0.75), size = 0.5) + 
  geom_linerange(aes(ymin = ci_lower_90, ymax = ci_upper_90), position = position_dodge(width = 0.75), size = 1) +
  geom_point(size = 1, position = position_dodge(width = 0.75) ) + 
  theme_minimal(base_size = 9) +
  theme_bw() +
  facet_wrap(Controls~.) +
  labs(y = "Coefficient for interaction between voting for PP and use of voting booth as a predictor of signs of discomfort", x = "Code of region ommitted")
uncomfortable_regionjk_plot

ggsave("04_plots/figured10.png", plot = uncomfortable_regionjk_plot, width = 20, height = 15, units = "cm")
